package com.example.buyticketlishi.utils;

import android.os.CountDownTimer;

import com.example.baselibrary.Utils.LogUtil;

public class TimeCountDownUtil {

    private static TimeOver timeOver;
    private static CountDownTimer timer;

    public static void CountDownTime(int tiem1) {
        timer = new CountDownTimer(tiem1*1000, 1000) {
          @Override
          public void onTick(long millisUntilFinished) {
              LogUtil.d(millisUntilFinished / 1000 + "");

          }

          @Override
          public void onFinish() {
              timeOver.timeOverNow();

          }
      };
        timer.start();
    }

    public static void CountDownTimeFinish(){
        if (timer != null) {
            timer.cancel();
        }
    }

    public interface TimeOver {
        void timeOverNow();
    }

    public static void setTimeOverListener(TimeOver time) {
        timeOver = time;
    }
}
